<%-- 
    Document   : error
    Created on : Apr 8, 2008, 4:33:25 PM
    Author     : mark
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <title>MR Grid Error Page</title>
        <link href="styles/pxgrid_style.css" rel="stylesheet" type="text/css" />
        <script src="javascript/spacegroups.js" type="text/javascript"></script>
    </head>
    <body>
        <%@ include file="header_banner.html" %>
        <div id="page">
            <%@ include file="menubar.html" %> 
            
            <!-- start content -->
            <div id="content">
                
                <%
                //an int which we'll switch on later
                int error_code = 0;
                
                //check if we've been passed an error code
                if(request.getParameter("errorcode")!= null) {
                        
                    //lets parse that error code to an int
                    try {
                        
                        error_code = Integer.parseInt(request.getParameter("errorcode"));
                    //in the event that we cannot parse an integer
                    } catch (Exception e) {
                        //lets just make ultra sure that error code is 0
                        error_code = 0;
                    }
                }
                
                //strings that get used to display the messages
                String title ="";
                String error_msg = "";
                
                //switch based on the error code we were passed, to set the title
                //and error_msg strings.
                switch(error_code) {
                    //an error of type unknown
                    case 0 :
                        title ="An unknown error has occurred!";
                        error_msg = "<p>There was a problem processing your submission. Please try resubmitting your request." +
                                    "<br/>If problems persist please contact <a href=\"mailto:ashley.buckle@med.monash.edu.au\" title=\"email Dr. Ashley Buckle\">Dr. Ashley Buckle</a>." +
                                    "</p>";
                        break;
                    //another kinda generic error, but it occurred during job submission
                    case 1 :
                        title ="An error has occurred while submitting your job!";
                        error_msg = "<p>There was a problem submitting your job. Please check your parameters and try re-submitting." +
                                    "<br/>If problems persist please contact <a href=\"mailto:ashley.buckle@med.monash.edu.au\" title=\"email Dr. Ashley Buckle\">Dr. Ashley Buckle</a>." +
                                    "</p>";
                        break;
                    //this one occurs when the job ID is null.
                    case 2 :
                        title ="An error has occurred while submitting your job!";
                        error_msg = "<p>Your job appears to have returned a null value while submitting. Please try re-submitting." +
                                    "<br/>If problems persist and you believe this to be a bug please contact <a href=\"mailto:ashley.buckle@med.monash.edu.au\" title=\"email Dr. Ashley Buckle\">Dr. Ashley Buckle</a>." +
                                    "</p>";
                        break;
                        
                    //occurs when user tries to upload their PDB files in a format
                    //other than TAR or Zip.
                    case 3 :
                        title ="MR Grid encountered an error with your PDB archive";
                        error_msg = "<p>Please check the archive you uploaded, it doesn't appear to be a TAR or Zip archive." +
                                    "<br/>If problems persist and you believe this to be a bug please contact <a href=\"mailto:ashley.buckle@med.monash.edu.au\" title=\"email Dr. Ashley Buckle\">Dr. Ashley Buckle</a>." +
                                    "</p>";
                        break;
                    
                    // case 4 removed. used to be for people who uploaded Zips instead of TARs
                    // seeing as we now have Zip support, it's useless.
                    

                    //occurs if we can't parse a users MTZ file.
                    case 5 :
                        title ="MR Grid encountered an error with your MTZ file";
                        error_msg = "<p>Please check the MTZ file you uploaded, MR Grid is having issues with it." +
                                    "<br/>If problems persist and you believe this to be a bug please contact <a href=\"mailto:ashley.buckle@med.monash.edu.au\" title=\"email Dr. Ashley Buckle\">Dr. Ashley Buckle</a>." +
                                    "</p>";
                        break;
                       
                    //we can't reach the controller, this != good
                    case 6 :
                        title ="Major error!";
                        error_msg = "<p>Unable to initiate the PXSubmissionController, something is wrong." +
                                    "<br/>If problems persist and you believe this to be a bug please contact <a href=\"mailto:ashley.buckle@med.monash.edu.au\" title=\"email Dr. Ashley Buckle\">Dr. Ashley Buckle</a>." +
                                    "</p>";
                        break;
                    
                    //we can't find the Xgrid definition file..
                    //ie. we have no idea where to submit to
                    case 7 :
                        title ="No Xgrid definition file";
                        error_msg = "<p>MR Grid can't find a Xgrid definitions file, without it there is no submission." +
                                    "<br/>If problems persist and you believe this to be a bug please contact <a href=\"mailto:ashley.buckle@med.monash.edu.au\" title=\"email Dr. Ashley Buckle\">Dr. Ashley Buckle</a>." +
                                    "</p>";
                        break;
                        
                    //the PDB files were extracted, but for some reason we can't open them
                    case 8 :
                        title ="An error has occurred while submitting your job!";
                        error_msg = "<p>MR Grid could not access one of the PDB files while submitting. Please try re-submitting." +
                                    "<br/>If problems persist and you believe this to be a bug please contact <a href=\"mailto:ashley.buckle@med.monash.edu.au\" title=\"email Dr. Ashley Buckle\">Dr. Ashley Buckle</a>." +
                                    "</p>";
                        break;
                        
                    //we can't create the directories needed for submission..
                    //check your permissions.
                    case 9 :
                        title ="An error has occurred while submitting your job!";
                        error_msg = "<p>MR Grid was unable to create the required directories for your submission. Please try re-submitting." +
                                    "<br/>If problems persist and you believe this to be a bug please contact <a href=\"mailto:ashley.buckle@med.monash.edu.au\" title=\"email Dr. Ashley Buckle\">Dr. Ashley Buckle</a>." +
                                    "</p>";
                        break;
                    //we couldn't move the MTZ file from a tmp location to where we want it
                    case 10 :
                        title ="An error has occurred while submitting your job!";
                        error_msg = "<p>MR Grid was unable to move uploaded MTZ file to the required directory for your submission. Please try re-submitting." +
                                    "<br/>If problems persist and you believe this to be a bug please contact <a href=\"mailto:ashley.buckle@med.monash.edu.au\" title=\"email Dr. Ashley Buckle\">Dr. Ashley Buckle</a>." +
                                    "</p>";
                        break;
                    
                    //we can't move the PDB files to where we need them
                    case 11 :
                        title ="An error has occurred while submitting your job!";
                        error_msg = "<p>MR Grid was unable to move uploaded PDB files to the required directory for your submission. Please try re-submitting." +
                                    "<br/>If problems persist and you believe this to be a bug please contact <a href=\"mailto:ashley.buckle@med.monash.edu.au\" title=\"email Dr. Ashley Buckle\">Dr. Ashley Buckle</a>." +
                                    "</p>";
                        break;
                    //this will probably never get called, but just in case.
                    //generic error!
                    default :
                        title ="An unknown error has occurred!";
                        error_msg = "<p>There was a problem processing your submission. Please try resubmitting your request." +
                                    "<br/>If problems persist please contact <a href=\"mailto:ashley.buckle@med.monash.edu.au\" title=\"email Dr. Ashley Buckle\">Dr. Ashley Buckle</a>." +
                                    "</p>";
                }
                
                %>
                    <h1 class="title"><% out.print(title); %></h1>
                    <div class="entry">
                        <% out.println(error_msg); %>
                    </div>
            </div>
            <!-- end content -->
        </div>
    </body>
</html>
